#include "gtest/gtest.h"
#include <libraries/sockets/UDPSocket.h>

namespace {

//// The fixture for testing class Foo.
//class UDPSocketTest : public ::testing::Test {
// protected:
//  // You can remove any or all of the following functions if its body
//  // is empty.
//    UDPSocket sender,receiver;

//  UDPSocketTest() {
//    // You can do set-up work for each test here.
//  }

//  virtual ~UDPSocketTest() {
//    // You can do clean-up work that doesn't throw exceptions here.
//  }

//  // If the constructor and destructor are not enough for setting up
//  // and cleaning up each test, you can define the following methods:

//  virtual void SetUp() {
//    // Code here will be called immediately after the constructor (right
//    // before each test).
//  }

//  virtual void TearDown() {
//    // Code here will be called immediately after each test (right
//    // before the destructor).
//  }

//  // Objects declared here can be used by all tests in the test case for Foo.
//};


// Tests that the Foo::Bar() method does Abc.
//TEST_F(TCPSocketClientTest, Nullatbeginning) {
////    TCPSocket client = TCPSocketClient::create("localhost",55555);
////  client.
////  EXPECT_EQ(0, f.Bar(input_filepath, output_filepath));
//}


TEST(AbstractSocketPort, PortsWithinRange){
    UDPSocket udp(30);
    EXPECT_ANY_THROW(udp.setLocalPort(66666)) << "Local Port out of range test (>65535)";
    EXPECT_ANY_THROW(udp.setRemotePort(66666)) << "Remote Port out of range test (>65535)";

    EXPECT_ANY_THROW(udp.setLocalPort(-1)) << "Local port out of range test (<0)";
    EXPECT_ANY_THROW(udp.setRemotePort(-1)) << "Remote port out of range test (<0)";

    EXPECT_ANY_THROW(udp.setLocalPort(0)) << "Local port out of range test (0)";
    EXPECT_ANY_THROW(udp.setRemotePort(0)) << "Remote port out of range test (0)";
}

TEST(AbstractSocketPort, PortNotAvailable){
    UDPSocket udp_first("localhost",55555,"localhost",44444);
    EXPECT_ANY_THROW(UDPSocket udp_second("localhost",55555,"localhost",44444))
                    << "Test exception when local port is already in use";
}

TEST(AbstractSocketIP, MalformedIP){
    UDPSocket udp(30);
    EXPECT_ANY_THROW(udp.setLocalIP("256.0.1.1")) << "Malformed IP";
}


// Tests that Foo does Xyz.
//TEST_F(TCPSocketClientTest, DoesXyz) {
//  // Exercises the Xyz feature of Foo.
//}


} // namespace

//int main(int argc, char **argv) {
//  ::testing::InitGoogleTest(&argc, argv);
//  return RUN_ALL_TESTS();
//}
